package com.lyy.weather.activity;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.widget.Adapter;
import android.widget.AdapterView;

import com.lyy.weather.R;
import com.lyy.weather.bean.City;
import com.lyy.weather.database.DatabaHelper;
import com.lyy.weather.database.DatabaseUtil;
import com.lyy.weather.fragment.WeatherChangeFragment;
import com.lyy.weather.layout.adapter.ChangeCityAdapter;
import com.lyy.weather.layout.adapter.WeatherHourlyAdapter;
import com.lyy.weather.layout.bean.CityChange;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class ChangeCityActivity extends AppCompatActivity {

    private DatabaHelper dbHelper;
    private Handler handler=new Handler(Looper.getMainLooper()){
        @Override
        public void handleMessage(@NonNull Message msg) {

        }
    };

    //更换碎片的方法1
    public void replaceFragment(Fragment fragment){
        //2.获取FragmentManager，在活动中可以直接通过调用getSupportFragmentManager()得到
        FragmentManager fragmentManager=getSupportFragmentManager();
        //3.开启一个事务，通过调用beginTransaction()方法开启
        FragmentTransaction transaction=fragmentManager.beginTransaction();
        //4.向容器内添加或替换碎片，一般使用replace()方法实现，需要传入容器的id和待添加的碎片实例
        transaction.replace(R.id.weather_change_fragment_layout,fragment);
        //5.提交事务，调用commit()方法完成
        transaction.commit();
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_change_city);

        replaceFragment(new WeatherChangeFragment(getSupportFragmentManager()));


    }

}
